package com.xinchen.aiowaste.base
import android.text.TextUtils
import android.widget.LinearLayout
import android.widget.TextClock
import android.widget.TextView
import com.kongqw.network.monitor.enums.NetworkState
import com.maple.utils.ext.toVisible
import com.xinchen.aiowaste.R
import com.maple.base.base.BaseFragment as Base
abstract class BaseFragment: Base(){



    open fun setTitle(title: String?) {
        if(!TextUtils.isEmpty(title)) {
            view?.findViewById<TextView>(R.id.tv_title_center)?.text = title
        }
    }


    open fun showClockTime() {
        view?.findViewById<TextClock>(R.id.tc_time)?.toVisible()
    }

    open fun onBackClick(m:() -> Unit) {
        view?.findViewById<LinearLayout>(R.id.ll_title_left)?.let {
            it.toVisible()
            it.setOnClickListener {
               m.invoke()
            }
        }
    }

    override fun onNetWorkChange(networkState: NetworkState) {
        super.onNetWorkChange(networkState)
        view?.findViewById<TextView>(R.id.tv_network_state)?.let {
            it.text = "网络状态：${networkState.name}"
            it.toVisible()
        }
    }
}